package controle;

import java.awt.KeyEventDispatcher;
import java.awt.event.KeyEvent;

import javax.swing.JOptionPane;

public class AtalhosListener implements KeyEventDispatcher {

	private static AtalhosListener instancia;
	
	private AtalhosListener(){}
	
	@Override
	public boolean dispatchKeyEvent(KeyEvent tecla) {
		if(tecla.getID() == KeyEvent.KEY_PRESSED){
			if (tecla.isControlDown()) {
				if (KeyEvent.VK_S == tecla.getKeyCode()) {
					Controle.getInstancia().salvar();
				} else if (KeyEvent.VK_N == tecla.getKeyCode()) {
					Controle.getInstancia().novo();
				} else if (KeyEvent.VK_A == tecla.getKeyCode()) {
					Controle.getInstancia().abrir();
				}
			}
			if (KeyEvent.VK_F8 == tecla.getKeyCode()) {
				Controle.getInstancia().compilar();
			} else if (KeyEvent.VK_F9 == tecla.getKeyCode()) {
				Controle.getInstancia().gerarCodigo();
			} else if (KeyEvent.VK_F1 == tecla.getKeyCode()) {
				Controle.getInstancia().mostraNomeEquipe();
			} 
		}
		return false;
	}

	public static KeyEventDispatcher getInstancia() {
		if(instancia == null){
			instancia = new AtalhosListener();
		}
		return instancia;
	}

}
